// This code is licensed under New BSD Licence. For details see project page at
// http://code.google.com/p/hrissan-cocoa-helpers/source/checkout
#import <Foundation/Foundation.h>
#import "Common.h"

@class SimpleHTTPLoader;

@protocol SimpleHTTPLoaderDelegate

-(void)loader:(SimpleHTTPLoader *)loader result:(NSMutableData *)result_data statusCode:(int)statusCode;

@end


@interface SimpleHTTPLoader : NSObject {
	NSPtr<NSURLConnection> conn;
	NSPtr<NSMutableData> result_data;
	int statusCode;
	
	id<SimpleHTTPLoaderDelegate> delegate;
}

@property (nonatomic, assign) IBOutlet id<SimpleHTTPLoaderDelegate> delegate;

-(id)initWithDelegate:(id<SimpleHTTPLoaderDelegate>)delegate;

-(void)result:(NSMutableData *)result_data statusCode:(int)statusCode;

+(NSString *)prepare_parameter:(NSString *)param;

-(bool)loading;
-(void)cancel_request;
-(void)send_request:(NSURLRequest *)request;

@end
